import 'package:flutter/material.dart';
import 'package:flutter_base_package/app/routes/app_pages.dart';
import 'package:flutter_base_package/app/themes/app_theme.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:get/get.dart';
import '../app/utils/common.dart';
import '../app/utils/toast_utils.dart';

class MainApp extends StatelessWidget {
  const MainApp({super.key});

  @override
  Widget build(BuildContext context) {
    return ToastUtils.init(
      GestureDetector(
        onTap: () => Common.dismissKeyboard(),
        child: _getMaterialApp(context),
      ),
    );
  }

  Widget _getMaterialApp(BuildContext context) {
    return GetMaterialApp(
      localizationsDelegates: const <LocalizationsDelegate<dynamic>>[
        GlobalMaterialLocalizations.delegate,
        GlobalWidgetsLocalizations.delegate,
        GlobalCupertinoLocalizations.delegate,
      ],
      supportedLocales: const [
        Locale('en', 'US'),
        Locale('zh', 'CN'),
      ],
      debugShowCheckedModeBanner: false,
      initialRoute: AppRoutes.initial,
      getPages: AppPages.pages,
      theme: AppThemes.themData,
      defaultTransition: Transition.rightToLeftWithFade,
    );
  }
}
